package cn.ucai.day04_SalSys;

public class EmpUtil {
	public static void delEmp(Emp emp) {
		
		System.out.println("开除了"+emp.getName());
	}
	public static double countYearSal(Emp emp) {
		double result =0.0;
		if(emp instanceof Administrator){
			result=(emp.getSal()*12);
		}else if(emp instanceof Tech){
			Tech tech=(Tech)emp;//强制类型转换，因为多态条件下父类无法调用子类中的方法
			result=(tech.getSal()*12+tech.getComm());
			}else if(emp instanceof Manager){
				Manager m=(Manager)emp;
				result=(m.getSal()*12+m.getBounds());
				}
		return result;
	}
	public static void main(String[] args) {
		Administrator admin= new Administrator();
		admin.setName("张三");
		
		delEmp(admin);//Emp emp = new Administrator()

		Tech tech=new Tech("李四",2,12,"开发",1);
		System.out.println(countYearSal(tech));
	}

}
